import { responseType } from "./responseType";

const loginForm = {
  username: "admin",
  password: "admin123",
  code: "1234",
  uuid: ""
}

let mocks = [
  {
    type: "post",
    url: "/api/login",
    response: (data) => {
      let resData: responseType = {
        code: 200,
        token: "",
        msg: "",
      }
      if(data.body.username != loginForm.username){
        resData.code = 500;
        resData.msg = "用户名或密码错误"
      }else if(data.body.password != loginForm.password){
        resData.code = 500;
        resData.msg = "用户名或密码错误"
      }else {
        resData.token = "12312313132132"
      }
      return resData;
    },
  },
  {
    type: "get",
    url: "/getInfo",
    response(data){
      let resData: responseType = {
        code: 200,
        data: {
          user: {userName: "admin"},
          avatar: "",
          roles: [1],
          permissions: ["11"]
        },
        msg: "",
      }
      return resData;
    }
  },
  {
    type: "post",
    url: "/logout",
    response: (data) => {
      let resData = {
        code: 200,
        data: null,
        message: "",
      }

      return resData;
    },
  },
]

export default mocks